Use Go regexp for autoImportSpecifierExcludeRegexes, remove regexp2#3245
Merged
jakebailey merged 1 commit intomainfrom Mar 26, 2026
Merged
Use Go regexp for autoImportSpecifierExcludeRegexes, remove regexp2#3245jakebailey merged 1 commit intomainfrom
jakebailey merged 1 commit intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR removes the regexp2 dependency from the TypeScript-Go codebase by switching autoImportSpecifierExcludeRegexes matching to Go’s standard regexp (RE2) engine in internal/modulespecifiers, aligning with the recent direction from #2407 to reduce/avoid regexp2 usage.
Changes:
- Replace
regexp2compilation/matching with Goregexp, including support for/.../icase-insensitive patterns. - Remove
github.com/dlclark/regexp2fromgo.mod/go.sum. - Remove the
regexp2license block fromNOTICE.txt.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| internal/modulespecifiers/util.go | Switch cached compilation/matching to regexp and map /.../i to RE2 via an inline case-insensitive wrapper. |
| go.mod | Drop the direct regexp2 dependency. |
| go.sum | Remove regexp2 checksums. |
| NOTICE.txt | Remove third-party notice entry for regexp2. |
andrewbranch
approved these changes
Mar 26, 2026
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With #2407 merged,
autoImportSpecifierExcludeRegexesis the only place we ever construct a regex derived from user input. We do that withregexp2today, to be ECMAScript compatible.However, I just don't think people should be sticking anything complicated in there. And indeed, on GitHub, only one preference uses a regex that is not within
re2syntax: https://github.com/reformcollective/reform-next-starter/blob/c75b23a1be762ea42ede3edf3e36d4fe1141eb43/.vscode/settings.jsonI think we should drop the
regexp2dep and just use Go'sregexppackage. This is a break for sure, but, I don't think this one feature warrants shipping an entirely separate regex engine.Shaves 368K off our binary, so that's something I guess.